#ifndef DATAMANGER_H
#define DATAMANGER_H

#include <QSqlDatabase>

class datamanger
{
public:
    static datamanger *getInstance();
    static void removeInstance();

    bool regist(QString name,QString pswd);
    int login(QString name,QString pswd);
    void setLoginStat(QString user, int stat);
    QStringList getAllUsers();

    bool insertGroup(QStringList users, QString groupName);
    void alterGroupInfo(QString user);
    void insertGroupInfo(QStringList users, QString groupName);
    bool insertGroupInfo(QString user, QString groupName);
    QStringList selectGroup(QString user);

    void createOneGroup(QStringList users, QString groupName);
    QStringList selectOneGroup(QString groupName);
    void insertOneGroupInfo(QStringList users, QString groupName);
    bool insertOneGroupInfo(QString user, QString groupName);

    bool inviteGroupInfo(QString user, QString groupName);

    bool insertFileInfo(QString filePath, QString fileName, QString user);
    QStringList selectFileName();
    QString selectFilePath(QString fileName);

    void insertMeetingInfo(QString meetingName, QString creator, QString ip, quint16 port, QString time);

private:
    datamanger();
    ~datamanger();
    static datamanger* instance;

    QSqlDatabase db;
    void tableInit();

};

#endif // DATAMANGER_H
